from fastapi import exceptions

from sqlalchemy.orm import Session

from apis_module.dao.user_dao import UserDao
from apis_module.jsonvo.user_vo import UserInfoUpdateRequest
from apis_module.model.users_model import Users

user_dao = UserDao()


class UserService:
    @classmethod
    def update_user_info(cls, query_db: Session, user_info: UserInfoUpdateRequest) -> Users:
        user = user_dao.update_user_info(user_info, query_db)
        if user is None:
            raise exceptions.HTTPException(status_code=404, detail="User does not exist")
        return user
